<?php
require_once 'ReservationView.php';
	class ReservationManager{
		public function validate($snum,$term,$ornum,$dateReserved,$amount,$remarks){
		
				if(is_numeric($snum)&&is_numeric($ornum)&&is_numeric($amount)&&($term!=""||$term!=null)&&($dateReserved!=""||$dateReserved!=null)){
						return true;
					}else{
						return false;
				}
		}
		
		public function insertReservation($snum,$term,$ornum,$dateReserved,$amount,$remarks){	
			$conn=oci_connect("naiad","1234","localhost/XE");
			if(!$conn){
				$err[] = "Connection error!". var_dump(oci_error());
				echo '<script> alert("'.$err.'") </script>';
				die();
				oci_close($conn);
			}
			else{
				$stres = oci_parse($conn,"insert into reservation(studentno,term,ornum,datereserved,amount,remarks) values(:studentno,:term,:ornum,:datereserved,:amount,:remarks)");
				oci_bind_by_name($stres, ":studentno", $snum);
				oci_bind_by_name($stres, ":term", $term);
				oci_bind_by_name($stres, ":ornum", $ornum);
				oci_bind_by_name($stres, ":datereserved", $dateReserved);
				oci_bind_by_name($stres, ":amount", $amount);
				oci_bind_by_name($stres, ":remarks", $remarks);
				$exec1 = oci_execute($stres);
				if($exec1==true){
					return 1;
				}
				oci_commit($conn);
				//oci_free_statement($stid);
				oci_close($conn);
			}	
		}		
	}//class
?>
